<!DOCTYPE html>
<html class="x-admin-sm">

<head>
  {include file="public/head"}
</head>

<body>
  {include file="public/breadcrumb"}
  <div class="x-body">
    <xblock>
      <button class="layui-btn" onclick="x_admin_show('添加管理员','/admin.php/Roles/add')">
        <i class="layui-icon"></i>添加
      </button>
      <span class="x-right" style="line-height:32px">共有&nbsp;<span style="color: #FF5722;font-weight: bold;">{$data.roles|count}</span>&nbsp;条数据</span>
    </xblock>
    <table class="layui-table">
      <thead>
        <tr>
          <th width="50">ID</th>
          <td>角色名称</td>
          <td width="150">操作</td>
        </tr>
      </thead>
      <tbody>
        {volist name="data.roles" id="vo"}
        <tr>
          <td>{$vo.gid}</td>
          <td>{$vo.title}</td>
          <td>
            <button class="layui-btn layui-btn-warm layui-btn-xs" onclick="x_admin_show('编辑角色','/admin.php/Roles/add?gid='+{$vo.gid})">编辑</button>
            <button class="layui-btn layui-btn-danger layui-btn-xs" onclick="del({$vo.gid})">删除</button>
          </td>
        </tr>
        {/volist}
      </tbody>
    </table>
  </div>
  <script>
    layui.use(['layer'],function(){
      $ = layui.jquery;
      layer = layui.layer;
    });


    // 删除
    function del(gid){
      layer.confirm('确定要删除吗？', {
          icon:3,
          btn: ['确定','取消']
        }, function(){
          $.post('/admin.php/roles/deletes',{'gid':gid},function(res){
            if(res.code>0){
              layer.alert(res.msg,{icon:2});
            }else{
              layer.msg(res.msg);
              setTimeout(function(){window.location.reload();},1000);
            }
          },'json');
        });
    }
  </script>
</body>

</html>